package test230325one;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/3/25 22:48
 */
public class Main {

    public static void main(String[] args) {
        User user1 = new User();
        user1.setName("库洛米");
        // 定义个波轮洗衣机
        WashingMachine washingMachine2 = new PulsatorWashingMachine();
        washingMachine2.setBrand("海尔兄弟");
        washingMachine2.setName("库洛米的洗衣机");
        washingMachine2.setPrice(100);
//        user1.buyWashingMachine(pulsatorWashingMachine);
        // 定义了滚筒洗衣机
        WashingMachine washingMachine1 = new DrumWashingMachine();
        washingMachine1.setBrand("111");
        washingMachine1.setName("222");
        washingMachine1.setPrice(333);
//        user1.buyWashingMachine(washingMachine1);
//        user1.use();
        show(washingMachine1);
        show(washingMachine2);

        String s = "";
        s.toString();

        Object object = new DrumWashingMachine();
        Object object2 = new PulsatorWashingMachine();
    }

    // 展示洗衣机的信息
    static void show(WashingMachine washingMachine){
        // 向下转型
        if (washingMachine instanceof DrumWashingMachine) {
            ((DrumWashingMachine) washingMachine).show();
        }
        if (washingMachine instanceof PulsatorWashingMachine) {
            ((PulsatorWashingMachine) washingMachine).show();
        }
    }
}
